//package com.icangya.lifePay;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.icangya.Utils.JSONUtils;
//import com.icangya.Value.FootBall;
//import com.icangya.Value.StaticValue;
//import com.icangya.domain.User;
//import com.icangya.lifePay.utils.SignUtil;
//import com.icangya.lifePay.http.HttpClientUtil;
//import com.icangya.service.IFootUserService;
//import com.icangya.weixin.sdk.WXPayUtil;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.HashMap;
//import java.util.TreeMap;
//
//
///**
// * 微信网页授权接口
// */
//@RestController
//@RequestMapping("/4")
//public class _4 {
//
//    @Resource
//    HttpClientUtil httpClientUtil;
//
//    @Autowired
//    private IFootUserService iFootUserService;
//
//    @ResponseBody
//    @GetMapping
//    public JSONObject post(HttpServletRequest request,HttpServletResponse response ,@RequestParam String money) {
//
//        String openId = ((User)request.getSession().getAttribute(FootBall.FOOT_USER_SESSION)).getOpenId();
//
//        //此处应该处理一下金额
//        int realmoney = 200000;
//
//        switch (money){
//            case "2" :
//                realmoney = 2;
//                break;
//            case "5" :
//                realmoney = 5;
//                break;
//            case "50" :
//                realmoney = 50;
//                break;
//            default:
//                realmoney = 200000;
//                return JSONUtils.getRoot(-1,"faild","bug");
////                break;
//        }
//
//        com.icangya.domain.PayBean payBean = iFootUserService.getPaybeanByStatus();
//        TreeMap<String, String> map = new TreeMap<>();
//        map.put("app_id",payBean.getMchId());
//        map.put("method","openapi.payment.auth.auth");
//        map.put("format","json");
//        map.put("sign_method","md5");
//        map.put("nonce", WXPayUtil.generateNonceStr());
//        map.put("version","1.0");
//
//        HashMap<String, Object> content = new HashMap<String, Object>();
//        // content.put("merchant_order_sn","20170613085324552787");
//        content.put("url", StaticValue.WX.BASE_URL+"/5?myopenid="+openId+"&money="+realmoney);
//
//        map.put("biz_content", JSON.toJSONString(content));
//
//        String secret= payBean.getMchKey();
//        String sign = SignUtil.createSign(map, secret);
//        map.put("sign",sign);
//
//        String post = httpClientUtil.post(payBean.getRequestUrl(), JSON.toJSONString(map));
//
//        JSONObject jsonObject = JSONObject.parseObject(post);
//        String result_code = String.valueOf(jsonObject.get("result_code"));
//        if ("200".equals(result_code)){
//            String authUrl = String.valueOf(jsonObject.getJSONObject("data").get("authUrl"));
//            try {
//                response.sendRedirect(authUrl);
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        }
//
////        return post;
//        return JSONUtils.getRoot(-2,"faild",post);
//    }
//
//
//}
